home *** CD-ROM | disk | FTP | other *** search
/ HyperLib 1997 Winter - Disc 1 / HYPERLIB-1997-Winter-CD1.ISO.7z / HYPERLIB-1997-Winter-CD1.ISO / オンラインウェア / PRG / MacPerl 506 appl folder.sit / MacPerl 506 appl folder / Mac_Perl_506r1m_appl / MacPerl.Specifics < prev    next >
Text File  |  1995-12-28  |  10KB  |  269 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6. THIS FILE IS NOW SUPERSEDED! Check macperl.html!
  7.  
  8.  
  9.  
  10.  
  11. Specific language features of MacPerl                Matthias Neeracher 27Dec94
  12.  
  13. This file describes differences between MacPerl and a typical Unix perl
  14. implementation. Much of this information can also be found at the end of
  15. PerlHelp. If you have 411, search for PerlノMacintoshノExtensions.
  16.  
  17. 1. VARIA
  18.  
  19. All time related functions measure time in seconds from 1904, not 1970 as in
  20. Unix.
  21.  
  22. "¥n" on a Mac means ASCII 13, as opposed to Unix, where it means ASCII 10.
  23.  
  24. Pathnames are specified as:
  25.  
  26. volume:folder:file                for absolute pathnames
  27. :folder:file                        for relative pathnames
  28. :file                                    for relative pathnames
  29. file                                    for relative pathnames
  30.  
  31. MacPerl has a limited capability to handle constructs like `command` or
  32. open(F, "|command"), if you are the lucky owner of ToolServer. Additionally, whether
  33. you have toolserver or not, `pwd` and `Directory` (case is significant) always return
  34. the current directory, followed by a newline.
  35.  
  36. 2. SOCKETS
  37.  
  38. MacPerl has more Socket families than Unix Perl. Additionally, there is a call
  39. choose() to allow the user to interactively specify addresses or file names. As
  40. there are lots of rather complicated data types, there is a library header "GUSI.ph"
  41. which defines packing/unpacking procedures.
  42.  
  43. Choose() is called as follows:
  44.  
  45. &MacPerl'Choose(DOMAIN,TYPE,PROMPT,CONSTRAINT,FLAGS,DEFAULT)
  46. &MacPerl'Choose(DOMAIN,TYPE,PROMPT,CONSTRAINT,FLAGS)
  47. &MacPerl'Choose(DOMAIN,TYPE,PROMPT,CONSTRAINT)
  48. &MacPerl'Choose(DOMAIN,TYPE,PROMPT)
  49.          Puts up a modal dialog prompting the user to choose an address. 
  50.          DOMAIN specifies the communication domain, like for socket().
  51.          TYPE may be used by future communication domains to further 
  52.          differentiate within a domain, but is ignored by current domains. 
  53.          PROMPT is a message that will appear in the dialog. CONSTRAINT may 
  54.          be set to a suitable packed value to restrict the types of acceptable
  55.          addresses.
  56.  
  57.          Examples:
  58.  
  59.          require "GUSI.ph";
  60.          
  61.          $file = 
  62.             &MacPerl'Choose(
  63.                &GUSI'AF_FILE, 0, "", 
  64.                &GUSI'pack_sa_constr_file("OBJ ", "TEXT"));
  65.                             
  66.                             Return the full pathname of an existing text
  67.                             or MPW object file.
  68.          
  69.          $dir = &MacPerl'Choose(&GUSI'AF_FILE, 0, "", "", &GUSI'CHOOSE_DIR);
  70.  
  71.                             Return the full pathname of an existing directory.
  72.                             
  73.          $file = 
  74.             &MacPerl'Choose(
  75.                &GUSI'AF_FILE, 0, "", "", 
  76.                &GUSI'CHOOSE_NEW + &GUSI'CHOOSE_DEFAULT, "yo");
  77.  
  78.                             Return the pathname of a new file to be created.
  79.                                      
  80. Socket families are:
  81.  
  82. Internet:
  83.  
  84. Packing addresses:    &GUSI'pack_sockaddr_in(family, address, port)
  85. Unpacking addresses:    (family, address, port) = &GUSI'unpack_sockaddr_in(addr)
  86. Choose:                    Not available.
  87.  
  88. Unix:
  89.  
  90. Packing addresses:    &GUSI'pack_sockaddr_un(family, path)
  91. Unpacking addresses:    (family, path) = &GUSI'unpack_sockaddr_un(addr)
  92. Choose:                    choose(&GUSI'AF_UNIX, 0, "", "", 0, "");
  93.                             looks up an existing address.
  94.                             choose(
  95.                                 &GUSI'AF_UNIX, 0, "Yes ?", "", 
  96.                                 &GUSI'CHOOSE_NEW + &GUSI'CHOOSE_DEFAULT, "yo");
  97.                             creates a new address.
  98.                             No constraints may be specified.
  99.  
  100. Appletalk (ADSP):
  101.  
  102. Packing addresses:    &GUSI'pack_sockaddr_atlk(family, net, node, socket)     (numerical)
  103.                             &GUSI'pack_sockaddr_atlk_sym(family, obj, type, zone)    (symbolic)
  104. Unpacking addresses:    (family, net, node, socket) = &GUSI'unpack_sockaddr_atlk(addr)
  105.                             (family, obj, type, zone) = &GUSI'unpack_sockaddr_atlk_sym(addr)
  106. Choose:                    choose(&GUSI'AF_APPLETALK, 0, "Eh ?", 
  107.                                 &GUSI'pack_sa_constr_atlk("LaserWriter", "GorillaWriter"),
  108.                                 0, "");
  109.                             looks up an existing address.
  110.                             New addresses may not currently be created with choose.
  111.  
  112. PPC Toolbox:
  113.  
  114. Packing addresses:    &GUSI'pack_sockaddr_ppc(family, type, name, porttype)
  115. Unpacking addresses:    Not available.
  116. Choose:                    choose(&GUSI'AF_PPC, 0, "Eh ?", 
  117.                                 &GUSI'pack_sa_constr_ppc("Gonkulator"),
  118.                                 0, "");
  119.                             looks up an existing address.
  120.                             New addresses may not currently be created with choose.
  121.  
  122.  
  123. 3. ADDITIONAL FUNCTIONS AVAILABLE IN MACPERL
  124.  
  125. &MacPerl'Answer(PROMPT)
  126. &MacPerl'Answer(PROMPT,BUTTON1)
  127. &MacPerl'Answer(PROMPT,BUTTON1,BUTTON2)
  128. &MacPerl'Answer(PROMPT,BUTTON1,BUTTON2,BUTTON3)
  129.           Presents to the user a dialog with 1, 2, or 3 buttons. 
  130.           
  131.           Examples:
  132.           
  133.           &MacPerl'Answer("Nunc et in hora mortis nostrae", "Amen");
  134.                               
  135.                             always returns 0.
  136.                             
  137.           &MacPerl'Answer("I refuse");
  138.           
  139.                               is equivalent to &MacPerl'Answer("I refuse", "OK");
  140.           
  141.           &MacPerl'Answer("Delete hard disk ?", "OK", "Cancel");
  142.                   
  143.                             returns 1 for OK, 0 for Cancel
  144.         
  145.           &MacPerl'Answer("Overwrite existig file", "Overwrite", "Skip", "Cancel");
  146.               
  147.                             returns 2 for Overwrite, 1 for Skip, 0 for Cancel
  148.                                      
  149. &MacPerl'Ask(PROMPT, DEFAULT)
  150. &MacPerl'Ask(PROMPT)
  151.           Asks the user for a string. A default value may be given. Returns
  152.           undef if the dialog is cancelled.
  153.           
  154.           Example:
  155.           
  156.           $phone = &&MacPerl'Ask("Enter your phone number:");
  157.           $name = &&MacPerl'Ask("Enter your first name", "Bruce");
  158.           
  159.                             Useful for Australian database applications
  160.                                      
  161. &MacPerl'Pick(PROMPT, VALUES)
  162.           Asks the user to pick a choice from a list. VALUES is a list of choices. 
  163.           Returns undef if the dialog is cancelled.
  164.           
  165.           Examples:
  166.           
  167.           $color = &MacPerl'Pick("What's your favorite color baby ?", "Red", "Green", "Gold");
  168.              
  169. &MacPerl'SetFileInfo(CREATOR,TYPE,FILE...)
  170.             Changes the file types and creators of the file(s).
  171.  
  172.             Examples:
  173.  
  174.             &MacPerl'SetFileInfo("MPS ", "TEXT", yin, yang);
  175.  
  176.                                     Turn yin and yang into MPW text files
  177.  
  178. &MacPerl'GetFileInfo(FILE)
  179.             In scalar context, returns the file type. In array context, returns
  180.             (creator,type).
  181.  
  182.             Examples:
  183.  
  184.             &MacPerl'GetFileInfo(yin);
  185.  
  186.                                     Returns "TEXT" or ("MPS ", "TEXT").
  187.  
  188. &MacPerl'DoAppleScript(SCRIPT)
  189.             Execute an AppleScript script.
  190.             
  191.             Example:
  192.             
  193.             &MacPerl'DoAppleScript(<<END_SCRIPT);
  194. tell application "MacPerl"
  195.     make new Window
  196.     copy "Inserting text the hard way." to character 1 of front Window
  197. end tell
  198. END_SCRIPT
  199.  
  200. &MacPerl'Reply(ANSWER)
  201.             Reply to current DoScript request. Useful if you are calling Perl 
  202.             scripts from other applications.
  203.             
  204. &MacPerl'Quit(LEVEL)
  205.             If LEVEL is 0, don't quit after ending the script. If 1, quit if 
  206.             running under a runtime version, if 2, always quit. If LEVEL is 3,
  207.             quit if this was the first script to be run since starting MacPerl.
  208.  
  209. &MacPerl'LoadExternals(LIBFILE)
  210.             Load XCMD and XFCN extensions contained in file LIBFILE, which is searched
  211.             along the same path as it would be for a require. The extensions are made
  212.             accessible in the current package, unless they conatin an explicit package
  213.             name.
  214.  
  215. &MacPerl'DebugExternals(DEBUGLEVEL)
  216.             If DEBUGLEVEL is 0, don't print any debug information for XCMDs and XFCNs. 
  217.             If 1, print information for unimplemented callbacks. If 2, print 
  218.             informations for all callbacks.
  219.  
  220. &MacPerl'FAccess(FILE, CMD, ARGS)
  221.             When called from the tool, manipulate various information of files. To 
  222.             get the command constants, it's convenient to require "FAccess.ph".
  223.  
  224.     $TAB = &MacPerl'FAccess(FILE, &F_GTABINFO)
  225.     &MacPerl'FAccess(FILE, &F_STABINFO, TAB)
  226.             Manipulate tabulator setting (in spaces per tab).
  227.             
  228.     ($FONTNAME, $FONTSIZE) = &MacPerl'FAccess(FILE, &F_GFONTINFO)
  229.     $FONTNUM = &MacPerl'FAccess(FILE, &F_GFONTINFO)
  230.     &MacPerl'FAccess(FILE, &F_SFONTINFO, FONT [, SIZE])
  231.             Manipulate font and size information. Both font names and font numbers
  232.             are accepted for F_SFONTINFO; F_GFONTINFO returns a font name in an
  233.             array context, a font number in a scalar context.
  234.             
  235.     ($STARTSEL, $ENDSEL, $DISPLAYTOP) = &MacPerl'FAccess(FILE, &F_GSELINFO)
  236.     $STARTSEL = &MacPerl'FAccess(FILE, &F_GSELINFO)
  237.     &MacPerl'FAccess(FILE, &F_SSELINFO, $STARTSEL, $ENDSEL [, $DISPLAYTOP])
  238.             Manipulate the MPW selection of a file.
  239.             
  240.     ($LEFT, $TOP, $RIGHT, $BOTTOM) = &MacPerl'FAccess(FILE, &F_GWININFO)
  241.     $TOP = &MacPerl'FAccess(FILE, &F_GWININFO)
  242.     &MacPerl'FAccess(FILE, &F_SWININFO, LEFT, TOP [, RIGHT, BOTTOM])
  243.             Manipulate the window position.
  244.  
  245. &MacPerl'MakeFSSpec(PATH)
  246.             This command encodes a path name into an encoding (volume #, directory #,
  247.             File name) which is guaranteed to be unique for every file. Don't store
  248.             this encoding between runs of MacPerl!
  249.  
  250. &MacPerl'MakePath(FSSPEC)
  251.             The inverse of &MacPerl'MakeFSSpec(): turn an encoding into a path name.
  252.  
  253. &MacPerl'Volumes()
  254.             In scalar context, return the FSSPEC of the startup volume. In list
  255.             context, return FSSPECs of all volumes.
  256.  
  257. 4. MACPERL SPECIFIC LIBRARIES
  258.  
  259. StandardFile.pl   Calls for standard file dialogs. A very convenient front end
  260.                   for &MacPerl'Choose()
  261.                         
  262. FindFolder.pl     Returns the path names of special folders (System, Preferences).
  263.  
  264. CommConnect.pl    Library for accessing the serial port.
  265.  
  266. GUSI.ph           Definitions for socket related calls.
  267.  
  268. FAccess.ph        Definitions for &MacPerl'FAccess() (MPW tool only).
  269.